package com.hp.controller;

import com.hp.pojo.User;
import com.hp.service.UserService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @RequestMapping("/toLogin")
    public String tologin(){
        return "login";
    }

    @RequestMapping("/toShow")
    public String toShow(){
        return "show";
    }


    @PostMapping("/login")
    public User login(@RequestBody User user){
        System.out.println(user.getUsername());
        User login = userService.login(user);
        System.out.println(user.getUsername());

       return login;
        
    }
}
